# server.publicDir

- **Type:**

```ts
type PublicDirOptions = {
  name?: string;
  copyOnBuild?: boolean;
  watch?: boolean;
};
type PublicDir = false | PublicDirOptions | PublicDirOptions[];
```

- **Default:**

```js
const defaultValue = {
  name: 'public',
  copyOnBuild: true,
};
```

By default, Rsbuild will use the `public` directory as the directory for serving public assets, files in this directory will be served at [server.base](/config/server/base) path (default `/`).

> Related document: [Public Folder](/guide/basic/static-assets#public-folder).

## Options

### name

- **Type:** `string`
- **Default:** `'public'`

The name of the public directory. The value of `name` can be set to a relative path or an absolute path. Relative path will be resolved relative to the project root directory.

- Relative path example:

```ts
export default {
  server: {
    publicDir: {
      name: '../some-public',
    },
  },
};
```

- Absolute path example:

```ts
import path from 'node:path';

export default {
  server: {
    publicDir: {
      name: path.join(__dirname, '../some-public'),
    },
  },
};
```

### copyOnBuild

- **Type:** `boolean`
- **Default:** `true`

Whether to copy files from the publicDir to the distDir on production build.

For example, disable `copyOnBuild`:

```ts
export default {
  server: {
    publicDir: {
      copyOnBuild: false,
    },
  },
};
```

Note that setting the value of `copyOnBuild` to false means that when you run `rsbuild preview` for a production preview, you will not be able to access the corresponding static resources.

:::tip
During dev builds, if you need to copy some static assets to the output directory, you can use the [output.copy](/config/output/copy) option instead.
:::

### watch

- **Type:** `boolean`
- **Default:** `false`

Whether to watch the public directory and reload the page when the files change.

Setting `watch` to `true` allows the dev server to watch changes to files in the specified public directory and reload the page when the files are changed:

```ts
export default {
  server: {
    publicDir: {
      watch: true,
    },
  },
};
```

Note that the `watch` option is only valid in development mode. If [dev.hmr](/config/dev/hmr) and [dev.liveReload](/config/dev/live-reload) are both set to false, `watch` will be ignored.

## Multiple Directories

The `server.publicDir` can be configured as an array, allowing you to serve multiple directories as static assets folders:

```ts
export default {
  server: {
    publicDir: [
      {
        name: 'public',
      },
      {
        name: 'assets',
        watch: false,
      },
    ],
  },
};
```

## Disabled

You can set `publicDir` to `false` to disable the static assets serving:

```ts
export default {
  server: {
    publicDir: false,
  },
};
```
